package com.superm.service.impl;

import com.alibaba.fastjson.JSON;
import com.superm.entity.RepostoryType;
import com.superm.mappers.RepostoryMapper;
import com.superm.service.RepostoryService;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.stereotype.Service;

import java.util.HashMap;
import java.util.List;
import java.util.Map;

@Service
public class RepostoryServiceImpl implements RepostoryService {
    @Autowired
    private RepostoryMapper repostoryMapper;
    @Override//查询查询全部仓库
    public List<RepostoryType> allRepostory() {
        return repostoryMapper.allRepostory();
    }

    @Override
    public Integer addRepostory(RepostoryType rep) {
        return repostoryMapper.addRepostory(rep);
    }

    @Override
    public Integer delRepostory(Integer repid) {
        return repostoryMapper.delRepostory(repid);
    }

    @Override
    public Integer upRepostory(RepostoryType rep) {
        return repostoryMapper.upRepostory(rep);
    }

    @Override
    public RepostoryType queryRid(Integer repid) {
        return repostoryMapper.queryRid(repid);
    }

    /**
     * 实现异步方式查询仓库信息
     * @param repid
     * @return
     */
    @Override
    public Map<String, Object> ajaxQuertRid(Integer repid) {
        Map<String,Object> map = new HashMap<String,Object>();
        map.put("code",0);
        RepostoryType repostoryType = repostoryMapper.queryRid(repid);
        map.put("data", JSON.toJSONString(repostoryType));
        return map;
    }

    @Override
    public Integer XRepcapCityxhao(Integer capCityxhao, Integer repid) {
        return repostoryMapper.XRepcapCityxhao(capCityxhao,repid);
    }
    @Override
    public Integer ZRepcapCityxhao(Integer capCityxhao, Integer repid) {
        return repostoryMapper.ZRepcapCityxhao(capCityxhao,repid);
    }
}
